support subsecond resolution for trackfilter start/stop options. (#1026)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Tue, 7 Mar 2023 14:32:59 +0000 (07:32 -0700)
committerGitHub <noreply@github.com>
Tue, 7 Mar 2023 14:32:59 +0000 (07:32 -0700)
* support subsecond resolution for trackfilter start/stop options.

* de-ickify track filter start/stop implementation.

trackfilter.cc
xmldoc/filters/options/track-start.xml

index 349ea190ac2d8601711f8103715f9215e525ce05..b1cd3119ed5eeac802a95207ae9255c9cfef7258 100644 (file)
@@ -676,17 +676,19 @@ QDateTime TrackFilter::trackfilter_range_check(const char* timestr)
 {
   QDateTime result;
 
-  static const QRegularExpression re("^(\\d{0,14})$");
+  QString start(timestr);
+  QString fmtstart("00000101000000.000");
+  fmtstart.replace(0, start.size(), start);
+
+  static const QRegularExpression re(R"(^\d{14}\.\d{3}$)");
   assert(re.isValid());
-  QRegularExpressionMatch match = re.match(timestr);
+  QRegularExpressionMatch match = re.match(fmtstart);
   if (match.hasMatch()) {
-    QString start = match.captured(1);
-    QString fmtstart("00000101000000");
-    fmtstart.replace(0, start.size(), start);
-    result = QDateTime::fromString(fmtstart, "yyyyMMddHHmmss");
+    // QTime::fromString zzz expects exactly 3 digits representing milliseconds.
+    result = QDateTime::fromString(match.captured(0), "yyyyMMddHHmmss.zzz");
     result.setTimeSpec(Qt::UTC);
     if (!result.isValid()) {
-      fatal(MYNAME "-range-check: Invalid timestamp \"%s\"!\n", qPrintable(start));
+      fatal(MYNAME "-range-check: Invalid timestamp \"%s\"!\n", timestr);
     }
 
 #ifdef TRACKF_DBG
index bb61ae63497977d67a69f1fffc479377556dbb4d..446de40d3d973e53046bb4dc6ad3d9fa10e837e6 100644 (file)
@@ -9,7 +9,7 @@ dawn of time or January 1, 1970, whichever was later.  The time for this
 option is expressed in UTC.
 </para>
 <para>
-The value of this option must be in the form of YYYYMMDDHHMMSS, but it is
+The value of this option must be in the form of YYYYMMDDHHMMSS.SSS, but it is
 not necessary to specify the smaller time units if they are not needed.
 That is, if you only care about points logged between 10 AM and 6 PM on a
 given date, you need not specify the minutes or seconds.